package com.xingzuo.library_user.ui.fragment;

import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.xingzuo.base.app.AppActivityKey;
import com.xingzuo.base.ui.mvp.base.adapter.BaseAdapter;
import com.xingzuo.base.ui.mvp.base.refresh.BaseRecyclerRefreshFragment;
import com.xingzuo.library_user.R;
import com.xingzuo.library_user.adapter.MyCaseAdapter;
import com.xingzuo.library_user.contract.CaseListContract;
import com.xingzuo.library_user.presenter.CaseListPresenter;

import java.util.ArrayList;

public class CaseListFragment extends BaseRecyclerRefreshFragment<CaseListContract.View, CaseListPresenter> {
    private int type;

    public CaseListFragment(int type) {
        this.type = type;
    }

    @Override
    public BaseAdapter createRecyclerAdapter() {
        if (type == 0){
            return new MyCaseAdapter(R.layout.item_case,new ArrayList<>());
        }else {
            return new MyCaseAdapter(R.layout.item_case_yigou,new ArrayList<>());
        }

    }

    @Override
    public CaseListPresenter getPresenter() {
        return new CaseListPresenter();
    }

    @Override
    public void initView() {
        getRefreshLayout().autoRefresh();
    }

    @Override
    public void initLinsenterner() {
        getRecyclerAdapter().setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                startIntent(AppActivityKey.CASEDETAILACTIVITY);
            }
        });
    }

    @Override
    public void getData() {

    }
}